package com.lagou.homework_1;

import org.apache.commons.lang.ObjectUtils;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RankReducer extends Reducer <RankBean, NullWritable, RankBean, NullWritable> {
    int rank = 0;
//    RankBean bean = new RankBean();
    @Override
    protected void reduce(RankBean bean, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
//        for (NullWriter value : values) {
//            rank ++;
//            bean.setRank(rank);
//            bean.setRaw_number(key.get());
//            context.write(bean, NullWritable.get());

//        }
        for (NullWritable value : values) {
            rank ++;
            bean.setRank(rank);
            context.write(bean, NullWritable.get());
        }
//        rank ++;
//        bean.setRank(rank);
//        context.write(bean, NullWritable.get());
    }
}
